1. Field of the Invention
The present invention relates to computer graphics technology. More specifically, the present invention relates to the evaluation of derivatives in screen space during graphics processing.
2. Related Art
Computer systems are extensively used to perform a wide variety of useful operations in modern society. Applications of computer systems can be found in virtually all fields and disciplines, including but not limited to business, industry, scientific research, education and entertainment. For instance, computer systems are used to analyze financial data, to control industrial machinery, to model chemical molecules, to deliver classroom presentations and to generate special effects for movies. Indeed, it has now come to the point where many of these operations have become so computationally intensive that they cannot be efficiently performed without the help of modern computer systems. As part of the process of performing such operations, computer systems typically utilize some type of display device, such as a cathode ray tube (CRT), a liquid crystal display (LCD) and the like, in order to display images and data which are recognizable to their users. As such, computer systems typically incorporate functionality for generating images and data which are subsequently output to the display device.
One technique for generating computer images and viewable data within a computer system is to utilize a graphics pipeline, which uses a series of interconnected functional blocks of circuitry, or xe2x80x9cstagesxe2x80x9d, to render an image. Each stage performs a unique task during each clock cycle. As soon as one stage has completed its task on a point (e.g., a pixel), that stage can immediately proceed to work on the next one. It does not have to wait for the processing of a prior pixel to complete before it can begin processing the current pixel. More specifically, sets of graphics primitives (e.g., triangles) are specified within the computer system and are subsequently sent down the graphics pipeline. Each stage sequentially performs a different function or functions on the received graphics primitives and then passes that data onto the following stage. Eventually, the graphics pipeline manipulates the graphics primitives in order to produce the final pixel values of an image. Thus, a graphics pipeline enables different graphics data to be processed concurrently, thereby generating graphics images at a higher rate. It should be appreciated that the functionality of a typical prior art graphics pipeline is well known by those of ordinary skill in the art.
One typical operation that is performed during graphics processing is texture mapping. Moreover, texture mapping generally involves the determination of the level of detail (LOD) at each point (e.g., a pixel) of the object (e.g., a triangle primitive) being texture mapped. In the prior art, the LOD of a given pixel is computed using various local difference techniques. In particular, one prior art implementation computes the LOD at a given pixel using differences in texture coordinates S and T of several adjacent pixels. For example, a typical prior art LOD computation uses four adjacent pixels (e.g., the four pixels form a two-by-two grid, or quad, within the triangle primitive being processed) to determine an LOD value, which is then applied to all four of the pixels. In other words, the LOD value that results is merely an approximation and is inexact with respect to each individual pixel. In most cases, such prior art implementation is subject to artifacts because each LOD computation is biased towards a certain direction depending on the manner in which the differences are computed and the location of the pixels within the primitive. Thus, it would be advantageous to provide a method and system for computing the LOD that can yield more accurate results and minimize the artifacts described above.
Moreover, in the prior art, the LOD at any given pixel is dependent upon the texture coordinates of its neighboring pixels. More specifically, since the LOD value is based upon the differences in the texture coordinates of adjacent pixels, the computation of the LOD requires that the texture coordinates of the pixels involved be calculated first. Due to the requirement that texture coordinates must be computed prior to LOD computations, the level of parallel processing in the graphics pipeline is significantly restricted. As such, this prior art implementation of LOD computation adversely impacts the efficiency of the graphics pipeline and thus lowers the overall performance of the computer system. Therefore, it would be beneficial to provide a method and system for computing the LOD that does not require the texture coordinates of adjacent pixels be first calculated such that the efficiency of the graphics pipeline as well as the overall performance of the computer system can be enhanced.
In summary, it would be highly advantageous to provide a method and system for computing the LOD that can yield more accurate results and minimize the artifacts associated with the prior art as described above. Moreover, it would also be advantageous to provide a method and system for computing the LOD that does not require the texture coordinates of adjacent pixels be first calculated such that the efficiency of the graphics pipeline and the overall performance of the computer system can be enhanced.
Accordingly, the present invention provides a method and system for computing the LOD at each point directly without having to rely on approximations. Such direct computation of the LOD for individual pixels in accordance with the present invention allows the exact LOD values to be easily computed and eliminates the artifacts that are inherent in prior art implementations. Moreover, the present invention provides a method and system for computing the LOD that does not require the texture coordinates of adjacent pixels as inputs. Thus, the present invention enables a higher level of parallel processing in the graphics pipeline, thereby greatly enhancing the efficiency and performance of the graphics pipeline and the computer system as a whole. These and other advantages of the present invention not specifically mentioned above will become clear within discussions of the present invention presented herein.
More specifically, a currently preferred embodiment of the present invention provides a method for computing the LOD at individual pixels directly during texture mapping. In this embodiment, screen coordinates of a pixel and texture coordinates of vertices of the triangle enclosing the pixel are determined. Derivatives of texture coordinates at the pixel with respect to screen space are evaluated by interpolation using barycentric coordinates of the pixel. Then, using the derivatives of the texture coordinates and without relying on neighboring pixels"" texture coordinates, the LOD at the pixel is computed, such that the LOD as computed is unbiased in any particular direction. Significantly, in accordance with the present invention, exact LOD values, rather than approximations based on local differences, are computed. This eliminates the artifacts that are inherent in prior art implementations such as those based on local differences techniques. This embodiment also enables a higher level of parallel processing by eliminating the need to compute texture coordinates prior to computing LOD, thereby enhancing system performance. Alternative embodiments of the present invention provide a computer system upon which the method of the present invention can be practiced. Moreover, in one embodiment, a triangular bilinear interpolator and a multiplier are included as part of the system hardware for performing the direct derivative computations in accordance with the present invention.
Yet another embodiment provides a method for computing derivatives of a function with respect to screen space, for any function that can be interpolated in eye space by perspective corrected barycentric coordinates for a point in screen space. The method of this embodiment can be used to evaluated any nth-order derivative where n is a positive integer. In this embodiment, coordinates of a triangle""s vertices in screen space are identified, where the triangle includes the point at which the derivatives are to be evaluated. Barycentric coordinates of the point, which specify a location of the point relative to the vertices of the triangle, are determined. Perspective correction factors for the point based on the coordinates of the vertices are also generated. The derivatives of the function are then expressed in interpolated form using the perspective correction factors, the barycentric coordinates of the point and values of the derivatives at the vertices. Finally, the derivatives are evaluated at the point using the interpolated equation such that the derivatives can be computed independently for that point without relying on data from neighboring points.